<template>
    <!-- <div class="main"> -->
        <div class="topNav">
            <div class="divImglogo">
                <img src="../../assets/logo3.png" alt="" class="pic">
                <!-- 图片为logo图 -->
            </div>
            <div class="header-right">
                <div class="header-user-con">
                    <!-- 全屏显示 -->
                    <div class="btn-fullscreen" @click="handleFullScreen">
                        <el-tooltip effect="dark" :content="fullscreen ? `取消全屏` : `全屏`" placement="bottom">
                            <i class="el-icon-rank"></i>
                        </el-tooltip>
                    </div>
                    <!-- 消息中心 -->
                    <div class="btn-bell">
                        <el-tooltip effect="dark" :content="message ? `有${message}条未读消息` : `消息中心`" placement="bottom">
                            <router-link to="/msg">
                                <i class="el-icon-bell"></i>
                            </router-link>
                        </el-tooltip>
                        <span class="btn-bell-badge" v-if="message"></span>
                    </div>
                    <!-- 用户头像 -->
                    <div class="user-avator">
                    <img src="../../assets/administration.png" />
                </div>
                    <!-- 用户名下拉菜单 -->
                    <el-dropdown class="user-name" trigger="click" @command="handleCommand">
                        <span class="el-dropdown-link">
                            {{$store.state.logininfo.UserName}}
                            <i class="el-icon-caret-bottom"></i>
                        </span>
                        <el-dropdown-menu slot="dropdown">
                            <el-dropdown-item>个人中心</el-dropdown-item>
                            <el-dropdown-item divided command="loginout">退出登录</el-dropdown-item>
                        </el-dropdown-menu>
                    </el-dropdown>
                </div>
            </div>

        </div>
    <!-- </div> -->
</template>

<script>
// import {} from '../../store/index'
export default {
    data() {
        return {
            collapse: false,
            fullscreen: false,
            message: 2
        };
    },
    methods:{    
        handleFullScreen() {// 全屏事件
            let element = document.documentElement;
            if (this.fullscreen) {
                if (document.exitFullscreen) {
                    document.exitFullscreen();
                } else if (document.webkitCancelFullScreen) {
                    document.webkitCancelFullScreen();
                } else if (document.mozCancelFullScreen) {
                    document.mozCancelFullScreen();
                } else if (document.msExitFullscreen) {
                    document.msExitFullscreen();
                }
            } else {
                if (element.requestFullscreen) {
                    element.requestFullscreen();
                } else if (element.webkitRequestFullScreen) {
                    element.webkitRequestFullScreen();
                } else if (element.mozRequestFullScreen) {
                    element.mozRequestFullScreen();
                } else if (element.msRequestFullscreen) {
                    // IE11
                    element.msRequestFullscreen();
                }
            }
            this.fullscreen = !this.fullscreen;
        },
        handleCommand(command) {//退出事件
            if (command == 'loginout') {
                localStorage.removeItem('ms_username');
                this.$router.push('/login');
            }else{
                this.$router.push('/login');
            }
        },
    
    },

}
</script>

<style scoped>
/* @import '../css/top.css' */
* {
    padding: 0;
    margin: 0;
}

.topNav {
    width: 100%;
    height: 100%;
    background-color: rgb(49, 73, 100);
    position: relative;
}

.divImglogo {
    display: inline-block;
    width: 90px;
    /* height: 90px; */
    /* border: 1px solid ; */
    margin-left: 100px;
}
.zhanghao{
    font-size: 17px;
    color: #fff;
    position: absolute;
    top: 47px;
    left: 153px;
    font-weight: 300;
}
.functionalAreas {
    float: right;
    margin-right: 100px;
    margin-top: 15px;
    height: 60px;
    color: rgb(209, 208, 208);
    /* 以下是弹性布局 */
    display: flex;
    align-items: center;
    justify-content: space-around;
    flex-direction: column;
}

.pic {
    width: 337px;
    position: absolute;
    top: 8px;
    left: 20px;
}

.adminShow {
    width: 130px;
    height: 25px;
    line-height: 25px;
    /* border: 1px solid; */
    text-align: center;
    border-radius: 10px;
    background-color: rgba(14, 47, 27, 0.404);
}

.spanBack {
    display: inline-block;
    width: 30px;
}

.header-right {
    /* float: right; */
    /* padding-right: 50px; */
    /* margin-right: 48px; */
    position:absolute;
    right: 20px;
    top: 10px;
    color: #fff;
    font-size: 16px;
    /* margin-top: 5px; */
}

.header-user-con {
    display: flex;
    height: 70px;
    align-items: center;
}

.btn-fullscreen {
    transform: rotate(45deg);
    margin-right: 5px;
    font-size: 24px;
    margin-top: 5px;
}

.btn-bell,
.btn-fullscreen {
    position: relative;
    width: 30px;
    height: 30px;
    text-align: center;
    border-radius: 15px;
    cursor: pointer;
}

.btn-bell-badge {
    position: absolute;
    right: 0;
    top: -2px;
    width: 8px;
    height: 8px;
    border-radius: 4px;
    background: #f56c6c;
    color: #fff;
}

.btn-bell .el-icon-bell {
    color: #fff;
    margin-top: 7px;
    font-size: 20px;
}

.user-name {
    margin-left: 10px;
}

.user-avator {
    margin-left: 20px;
}

.user-avator img {
    display: block;
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.el-dropdown-link {
    color: #fff;
    cursor: pointer;
    font-size: 20px;
}

.el-dropdown-menu__item {
    text-align: center;
    width: 80px;
    margin: -5px;
    /* padding: 10px; */
}
.el-dropdown-menu__item--divided:before {
    content: '';
    height: 6px;
    display: block;
    margin: 0 -20px;
    /* background-color: #FFF; */
}
</style>
